import express from "express";
import * as TaskController from "../controller/textItemController.js";

export default (db) => {
  const router = express.Router();

  // 获取所有文本项（不分页）
  router.get("/", (req, res) => TaskController.getAll(req, res, db));

  // 分页获取文本项
  router.get("/paged", (req, res) =>
    TaskController.getPagedItems(req, res, db)
  );

  // 创建新文本项
  router.post("/", (req, res) => TaskController.createItem(req, res, db));

  // 获取单个文本项
  router.get("/:id", (req, res) => TaskController.getItemById(req, res, db));

  // 更新文本项
  router.put("/:id", (req, res) => TaskController.updateItem(req, res, db));

  // 删除文本项（硬删除）
  router.delete("/:id", (req, res) => TaskController.deleteItem(req, res, db));

  // 软删除文本项
  router.patch("/:id/soft-delete", (req, res) =>
    TaskController.softDeleteItem(req, res, db)
  );

  return router;
};
